package com.quan.configuration;

import javax.servlet.Filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.quan.common.filter.TokenFilter;

/**
 * Filter 过滤器注册
 * @author yhaoquan
 *
 */
@Configuration
public class FilterConfiguration {

	/**
	 * 将TokenFilter注册到容器中
	 * @return
	 */
	@Bean
	public FilterRegistrationBean<Filter> tokenFilterRegistration() {
		FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<Filter>() ;
		registration.setFilter(tokenFilter());
		registration.addUrlPatterns("/*");
		registration.setName("TokenFilter");
		registration.setOrder(1);
		
		return registration;
	}
	
	@Bean
	public Filter tokenFilter() {
		return new TokenFilter() ;
	}
	
}
